import * as echarts from '../../ec-canvas/echarts'; //引入ec-canvas 

function initChart(canvas, width, height, dpr) {

    const chart = echarts.init(canvas, null, {
        width: width,
        height: height,
        devicePixelRatio: dpr //解决小程序视图模糊的问题，必写
    });
    canvas.setChart(chart);
    const option = {
        title: {
            text: '垃圾分类',
            top: '3%',
            textStyle: {
                fontSize: 13,
                fontWeight: 'bold',
                color: 'rgba(38,36,36,1)'
            }
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['干垃圾', '湿垃圾'],
            bottom: 0,
            itemWidth: 5
        },
        grid: {
            left: "3%",
            right: "4%",
            bottom: "15%",
            width: "90%",
            height: "65%",
            containLabel: true,
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周七']
        },
        yAxis: {
            type: 'value'
        },
        series: [{
                name: '干垃圾',
                type: 'line',
                symbol: "none",
                smooth: true,
                data: [120, 132, 101, 134, 90, 230, 210]
            },
            {
                name: '湿垃圾',
                type: 'line',
                symbol: "none",
                smooth: true,
                data: [220, 182, 191, 234, 290, 330, 310]
            }
        ]
    };
    //  option.series[0].data=recordData;
    chart.setOption(option);
    return chart;

}

Page({
    data: {
        //option:[],
        ec: {
            onInit: initChart
        }, //该部分是初始化函数,将数据填充表格，然后绘制表格
        ec1: {
            onInit: initChart
        }, //该部分是初始化函数,将数据填充表格，然后绘制表格
    },
})